package com.techstar.ats.codec.history.decoder;

import io.netty.buffer.ByteBuf;
import com.techstar.ats.codec.DateTimeCodec;
import com.techstar.ats.codec.Decoder;
import com.techstar.ats.codec.StringCodec;
import com.techstar.ats.dxp.history.F23HistoryRecord;
import com.techstar.ats.type.DirectionType;

public enum F23HistoryRecordDecoder implements Decoder<F23HistoryRecord> {
	INSTANCE;

	public F23HistoryRecord create() {
		return new F23HistoryRecord();
	}

	public void decode(ByteBuf buf, F23HistoryRecord value) {
		value.station = buf.readUnsignedShort();
		value.platform = buf.readUnsignedShort();
		value.arriveTime = DateTimeCodec.INSTANCE.get(buf);
		value.departTime = DateTimeCodec.INSTANCE.get(buf);
		value.dir = DirectionType.valueOf(buf.readUnsignedShort());
		value.train = (new StringCodec(9)).get(buf);
		value.global = (new StringCodec(12)).get(buf);
		value.dest = (new StringCodec(4)).get(buf);
		value.plan = 0 != buf.readUnsignedShort();
		buf.skipBytes(4);
	}
}
